home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Disc to the Future 2
/
Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin
/
MAC
/
THINKC
/
4_0
/
STANDALO
/
COMMENTF
/
ABOUT_CO.MME
next >
Wrap
Text File
|
1990-04-22
|
4KB
|
108 lines
About the CommentFKEY...
This is an FKEY to make it easier for C programmers to comment portions
of their code. This is mainly for documentation purposes, but it
does help a with debugging, because you can quicky comment in and
out suspect portions.
Install the FKEY in your System file using ResEdit, or open the file
with Suitcase or a similar utility. The FKEY is currently numbered 6,
but that can be changed.
Select the portion of text you want commented, copy it to the clipboard,
and hit command-shift-6. If you hit no other keys for 3/4 of a second,
the FKEY will do its default operation. By pressing other keys before
3/4 of a second expires, you can make other choices; they are described below.
The default choice is to surround the text with a box like this:
/*----------------------------------------------------------------------------+
| |
| This text is surrounded with a box. It stands out on the screen. |
| It looks important! |
| |
+----------------------------------------------------------------------------*/
If the text you select already has the top and bottom of the box in it, they
will be ignored. This way you can edit boxed text, select it and re-box
it without needing to delete the top and bottom lines. It's a little
hard to describe how it works, but you'll see when you play with it.
NOTE: this FKEY works best if you select entire lines, including end-of-line
characters.
If you press the option key within 3/4 of a second after calling the FKEY,
the text will be indented with a tab, and a line of marks will be
placed to its left, like this:
/*
* This text has a line going down its left side.
* It doesn't look so important, but is good for
* writing short notes.
*/
/*
* The line starts at the same indent level
* as the text was originally.
*/
Like the box feature, this will try to determine if the text was already
given a line before, and if so, do the smart thing. You can edit
text with a line on its left and call the FKEY again. As before, it's
easier for you to play with it than for me to describe it.
If you press the tab key within 3/4 of a second, the text will be surrounded
with /* and */ characters on separate lines, and any existing comments will
be replaced with |* and *| (this is because C doesn't allow commented comments,
or at least my C compiler doesn't). Example:
/*
if ( *inT == '/' && *(inT+1) == '*' ) {
|* skip this line *|
while ( inT < endT && *inT != '\r' ) { inT++; }
if ( inT < endT )
inT++;
continue;
}
if ( (*inT == '*' && *(inT+1) == '/') ||
(*inT == '/' && *(inT-1) == '*') ) {
|* skip this line *|
while ( inT < endT && *inT != '\r' ) { inT++; }
if ( inT < endT )
inT++;
continue;
}
*/
This way, you can select a portion of code and temporarily comment
it out without worrying about any comments already in the code.
If you press the "`" key within 3/4 of a second after calling the FKEY,
it will be assumed that the text on the clipboard was previously
commented with the tab key. It will remove anything outside the first
level of comments (/* and */), and replace any |* and *| strings with
/* and */; it undoes what the tab key does. If the text you copy
has no /* and */ characters, the FKEY just replaces any |* and *|
strings it finds.
BUGS:
1) The behavior of the FKEY is designed mainly for my tastes, but the
source is included so you can change it if you'd like. In particular,
all the commenting characters are #defined, so you can change those and
recompile if you'd like.
2) It doesn't necessarily work right for long lines.
3) If your editor doesn't use the TEScrap or the Desk Scrap, but uses a
private scrap, the FKEY probably won't work. The only program that I found
did this, though, was Word. I would guess other word processors do as well.
How to I easily trick a program to put its text on the clipboard?
The FKEY and code is free, but is copyrighted 1990 by David Fry and cannot
be resold.
Have fun!
David Fry
81 Irving Street
Cambridge, MA 02138
INTERNET: fry@math.harvard.edu